{% extends '::backend.html.twig' %}
{% block contenido %}
{% block documentReadyJavascript %} 
    {{ parent() }}
    <script type="text/javascript" >      
        $("#buttonFilter").click(function () {
            if ($("#divFilter").css('display') == 'none') {
                    $("#divFilter").show("slow");
                    $("#icono").attr("class", "icon-minus");
            } else {
                $("#divFilter").hide("slow");
                $("#icono").attr("class", "icon-plus");
            }
        });
    </script>
     <script type="text/javascript" >
        $(".delete").on('click', function(e){
                e.preventDefault()
                $this = $(this);
                $("#confirmation-dialog").dialog({
                resizable: false,
                height:180,
                width:'auto',
                modal: true,
                title:"Alerta!",
                buttons: {
                    "Eliminar": function() {
                        $this.parent().submit();
                    },
                    Cancelar: function() {
                        $( this ).dialog( "close" );
                    }
                }
            });
        });
    </script>
{% endblock documentReadyJavascript %}
    {% include 'BackendBundle:Default:flashAlerts.html.twig'%}
     <a class="btn  btn-success" href="{{ path('persona_new') }}">
        <i class="icon-plus" ></i>Agregar Persona
    </a>
    {% if entities %} 
    <fieldset>
        <a id="buttonFilter" href="javascript:void(0)"> <legend><i id="icono" class="icon-plus"></i>Filtros</legend></a>
        <div id="divFilter" style="display: none;">
        <form id="searchPersona" action="{{ path('persona')}}" method="POST" >
            {{ form_widget(searchForm._token) }}       
              <table class="table table-bordered">
                  <tr>
                      <td>Dni</td>
                      <td> {{ form_widget(searchForm.dni) }}</td>
                  </tr>
                  <tr>
                      <td>Apellido</td>
                      <td>{{ form_widget(searchForm.apellido) }}</td>
                  </tr>
                  <tr>    
                      <td>Nombre</td>
                      <td>{{ form_widget(searchForm.nombre) }}</td>
                  </tr>
              </table>
              <input class="btn btn-info" type="submit" value="Filtrar">
              <a class="btn btn-inverse btn-small" href="{{ path('persona')}}">Quitar Filtro</a>
        </form>
        </div>
    </fieldset>
          
<legend>Personas</legend>
<table class="table table-striped table-bordered table-striped table-hover">
    <thead>
        <tr>
            <th>Dni</th>
            <th>Apellido</th>
            <th>Nombre</th>
            <th>Email</th>
            <th>Teléfono</th>
            <th>Acciones</th>
        </tr>
    </thead>
    <tbody>
    {% for entity in entities %}
            <tr>
                <td><a href="{{ path('persona_show', { 'id': entity.id }) }}">{{ entity.dni }}</a></td>
                <td>{{ entity.apellido }}</td>
                <td>{{  entity.nombre  }}</td>               
                <td>{{ entity.email }}</td>
                <td>{{ entity.telefono }}</td>
                <td valign="middle" align="center">
                    <a class="btn btn-info  btn-small" href="{{ path('persona_show', { 'id': entity.id }) }}">
                        <i class=" icon-plus"> </i> info</i>
                    </a>
                    {% include 'BackendBundle:Default:accionesConPermisos.html.twig' with {'basePath':'persona','esEditor':true}%}
                </td>

            </tr>
    {% endfor %}
        </tbody>
    </table>
{% include 'BackendBundle:Default:paginador.html.twig' with { 'ruta': 'persona' } only %}
{% else %}
    <h3>{{ "No se encontraron personas" }}</h3>
{% endif %}
{% if (app.session.get('s_isSearch')) %}
   <script type="text/javascript" >
       $("#divFilter").show("slow");
       $("#icono").attr("class", "icon-minus");
    </script>   
{% endif %}
    <div id="confirmation-dialog" style="display:none">
    <div class="alert alert-error">
        <strong>Borrara!</strong>  la persona por completo, está seguro?
    </div>
</div>
{% endblock %}